<!DOCTYPE html>
<html>
{include file='/common/_meta'}
<script type="text/javascript" src="__admin__/layui/layui.js"></script>


<body>
    <!-- 头部 -->
{include file='/common/top'}
    <!-- /头部 -->
    
    <div class="main-container container-fluid">
        <div class="page-container">
                        <!-- Page Sidebar -->
        {include file='/common/left'}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <a href="{:url('Index/index')}">系统</a>
                        </li>
                        <li>
                            <a href="">商品管理</a>
                        </li>
                        <li class="active">数据恢复</li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">



<!-- <div class="layui-form">
 -->   
    <a class="btn btn-sm btn-azure btn-addon" href="javascript:;" autocomplete="off"> 数据库还原  </a>
    <div class="row">
        <div class="col-lg-12 col-sm-12 col-xs-12">
            <div class="widget">
                <div class="widget-body">
                    <div class="flip-scroll">
                        <table class="table table-bordered table-hover">
                            <thead>
                                <tr>

                                    <th class="text-center">数据库名称</th>
                                    <th class="text-center">卷数</th>
                                    <th class="text-center">压缩</th>
                                    <th class="text-center">数据大小</th>
                                    <th class="text-center">备份时间</th>
                                    <th class="text-center">状态</th>
                                    <th class="text-center">操作</th>
                                </tr> 
                            </thead>
                            <tbody>
                                {foreach name='list' item='data'}   
                                <tr>
                                    <td class="text-center">{$data.time|date='Ymd-His',###}</td>
                                    <td class="text-center">{$data.part}</td>
                                    <td class="text-center">{$data.compress}</td>
                                    <td class="text-center">{$data.size|format_bytes}</td>
                                    <td class="text-center">{$key}</td>
                                    <td class="status text-center" style="width: 200px;">-</td>
                                    <td class="action text-center">
                                        <a class="btn btn-primary btn-sm shiny db-import" href="{:url('data/import',['time'=>$data['time']])}">还原</a>&nbsp;
                                        <a class="btn btn-danger btn-sm shiny" href="{:url('data/del',['time'=>$data['time']])}">删除</a>
                                    </td>
                                </tr>
                                {/foreach}
                            </tbody>
                            <script>
                                layui.use(['jquery','layer'],function(){
                                      window.$ = layui.$;
                                      var layer = layui.layer;


                                      $(".db-import").click(function(){
                                            var self = this, status = ".";

                                            $(this).parent().prevAll('.status').html("").html('等待还原');

                                            $.get(self.href, success, "json");
                                            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
                                            return false;
                                        
                                            function success(data){

                                                if(data.code==1){

                                                    $(self).parent().prev().text(data.msg);

                                                    if(data.data.part){
                                                        $.get(self.href, 
                                                            {"part" : data.data.part, "start" : data.data.start}, 
                                                            success, 
                                                            "json"
                                                        );
                                                        
                                                    }  else {
                                                        layer.alert(data.msg);
                                                        //window.onbeforeunload = function(){ return null; }
                                                    }
                                                } else {
                                                    layer.alert(data.msg);
                                                }
                                            }
                                        });

                                    //   $(".db-import").click(function(){
                                    //     // console.log($(this).parents().find(".status").html() );//正常
                                    //     // console.log($(this).parent().prevAll('.status').html() );
                                    //     var statusem=$(this).parent().prevAll('.status');
                                    //     $(this).parent().prevAll('.status').html("").html('等待还原');
                                    //     thisobj=this;
                                    //     $.post(this.href, function(data){
                                         
                                    //       if(data.code==1){
                                    //         // statusem.text(""); // 清空数据
                                    //         // statusem.append('data'); 
                                    //         // statusem.text("").append('132');
                                    //         // $(this).parent().prevAll('.status').html("").html(data.msg);//error ：异常原因无法获取当前节点
                                    //         statusem.html(data.msg);
                                    //         getdbimport(thisobj,data.data);
                                    //       }
                                    //     }, "json");
                                    //     return false;
                                    // });

                                    });

                                </script>

                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
                  </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
        </div>  
    </div>

        <!--Basic Scripts-->
    {include file='/common/footer'}
    

</body></html>